<?php
class Admin_Model_Products extends Zend_Db_Table_Abstract{
	protected $_name = "products";
	protected $_primary = "prID";
	
	public function show_products(){
		$query = $this -> select();
		$query->setIntegrityCheck(false);
		$query->from(array('p' => 'products'),
				array('prID', 'prName','prDescribe','prImage','prCaID','prState'));
		$query->join(array('c' => 'catalogs'),
				'p.prCaID = c.caID');	
		$data = $this-> fetchAll($query);
		return $data -> toArray();
	}
	
	public function show_product_where($id)
	{
		$query = $this -> select();
		$query->from('products');
		$query->where('prID= ?', $id);
		$data = $this-> fetchAll($query);
		return $data -> toArray();
	}
	
	public function insert_product($data){
		$this->insert($data);
	}
	
	public function delete_product($id){
		$where="prID=".$id;
    	$this->delete($where);
	}

	public function update_product($id,$data){		
		$where = "prID=".$id;
		$this->update($data,$where);
		
	}
	public function lock($id,$data){
		$where = "prID=".$id;
		$this->update($data,$where);
	}

}